package org.jeecg.modules.fk.core.rest;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
import java.io.Serializable;

@JsonInclude(Include.NON_NULL)
public class RestResponseHead implements Serializable {
    private static final long serialVersionUID = -1879937950907235155L;
    public static final String SUCCESS_CODE = "0";
    public static final String REDIRECT_CODE = "302";
    private String requestId;
    private String errorCode = "0";
    private String errorMsg = null;
    private long timestamp = System.currentTimeMillis();
    private long time;
    private long gtime;
    private String errorNo;

    public RestResponseHead() {
    }

    public RestResponseHead(String requestId, String errorCode, String errorMsg) {
        this.requestId = requestId;
        this.errorCode = errorCode;
        this.errorMsg = errorMsg;
        this.timestamp = System.currentTimeMillis();
        this.time = 0L;
    }

    public RestResponseHead(String requestId, String errorCode, String errorMsg, long timestamp, long time) {
        this.requestId = requestId;
        this.errorCode = errorCode;
        this.errorMsg = errorMsg;
        this.timestamp = timestamp;
        this.time = time;
    }

    public boolean isSuccess() {
        return this.errorCode == null || this.errorCode.equals("0") || this.errorCode.equals("302");
    }

    public boolean isError() {
        return !this.isSuccess();
    }

    public String getRequestId() {
        return this.requestId;
    }

    public void setRequestId(String requestId) {
        this.requestId = requestId;
    }

    public String getErrorCode() {
        return this.errorCode;
    }

    public void setErrorCode(String errorCode) {
        this.errorCode = errorCode;
    }

    public String getErrorMsg() {
        return this.errorMsg;
    }

    public void setErrorMsg(String errorMsg) {
        this.errorMsg = errorMsg;
    }

    public long getTimestamp() {
        return this.timestamp;
    }

    public void setTimestamp(long timestamp) {
        this.timestamp = timestamp;
    }

    public long getTime() {
        return this.time;
    }

    public void setTime(long time) {
        this.time = time;
    }

    public long getGtime() {
        return this.gtime;
    }

    public void setGtime(long gtime) {
        this.gtime = gtime;
    }

    public String getErrorNo() {
        return this.errorNo;
    }

    public void setErrorNo(String errorNo) {
        this.errorNo = errorNo;
    }

    public boolean isRedirect() {
        return "302".equals(this.errorCode);
    }
}
